﻿#region Copyright (c) 2012-10, Olaf Kober <amarok.projects@gmail.com>
//================================================================================
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//	copies of the Software, and to permit persons to whom the Software is
//	furnished to do so, subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in
//	all copies or substantial portions of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//	THE SOFTWARE.
//================================================================================
#endregion

#if TESTS

using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Threading;
using NUnit.Framework;


namespace Amarok
{
	[TestFixture]
	public class Test_Helper
	{
		#region Constants

		[Test]
		public void Test_Constants()
		{
			Assert.That(Helper.KiloByte, Is.EqualTo(1024));
			Assert.That(Helper.MegaByte, Is.EqualTo(1024 * 1024));
			Assert.That(Helper.GigaByte, Is.EqualTo(1024 * 1024 * 1024));
			Assert.That(Helper.TeraByte, Is.EqualTo((Int64)1024 * 1024 * 1024 * 1024));
		}

		#endregion

		#region Dispose

		[Test]
		public void Test_Dispose()
		{
			var signal = new ManualResetEvent(false);
			Assert.That(signal.SafeWaitHandle.IsClosed, Is.False);

			Helper.Dispose(signal);
			Assert.That(signal.SafeWaitHandle.IsClosed, Is.True);
		}

		[Test]
		public void Test_Dispose_NullReference()
		{
			Helper.Dispose(null);
		}

		#endregion

		#region EmptyBytes

		[Test]
		public void Test_EmptyBytes()
		{
			Assert.That(Helper.EmptyBytes, Is.Not.Null);
			Assert.That(Helper.EmptyBytes, Is.SameAs(Helper.EmptyBytes));
			Assert.That(Helper.EmptyBytes, Has.Length.EqualTo(0));
		}

		#endregion

		#region EmptyChars

		[Test]
		public void Test_EmptyChars()
		{
			Assert.That(Helper.EmptyChars, Is.Not.Null);
			Assert.That(Helper.EmptyChars, Is.SameAs(Helper.EmptyChars));
			Assert.That(Helper.EmptyChars, Has.Length.EqualTo(0));
		}

		#endregion

		#region EmptyStrings

		[Test]
		public void Test_EmptyStrings()
		{
			Assert.That(Helper.EmptyStrings, Is.Not.Null);
			Assert.That(Helper.EmptyStrings, Is.SameAs(Helper.EmptyStrings));
			Assert.That(Helper.EmptyStrings, Has.Length.EqualTo(0));
		}

		#endregion

		#region ExpandTextText

		private String _ExpandTextTextLookup(String key)
		{
			Assert.That(key, Is.Not.Null);
			return '_' + key + '_';
		}



		[Test]
		public void Test_Null()
		{
			Assert.That(Helper.ExpandText(
				null,
				_ExpandTextTextLookup), Is.EqualTo(
				null
			));
		}

		[Test]
		public void Test_Empty()
		{
			Assert.That(Helper.ExpandText(
				"",
				_ExpandTextTextLookup), Is.EqualTo(
				""
			));
		}

		[Test]
		public void Test_Whitespaces()
		{
			Assert.That(Helper.ExpandText(
				"  ",
				_ExpandTextTextLookup), Is.EqualTo(
				"  "
			));
		}

		[Test]
		public void Test_SingleChar()
		{
			Assert.That(Helper.ExpandText(
				"a",
				_ExpandTextTextLookup), Is.EqualTo(
				"a"
			));
		}

		[Test]
		public void Test_CharsWithWhitespaces()
		{
			Assert.That(Helper.ExpandText(
				" a  ",
				_ExpandTextTextLookup), Is.EqualTo(
				" a  "
			));
		}

		[Test]
		public void Test_OnlyText()
		{
			Assert.That(Helper.ExpandText(
				"abcdef",
				_ExpandTextTextLookup), Is.EqualTo(
				"abcdef"
			));
		}

		[Test]
		public void Test_SingleExpansion_EmptyKey()
		{
			Assert.That(Helper.ExpandText(
				"abc$()def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc__def"
			));
		}

		[Test]
		public void Test_SingleExpansion_SingleCharKey()
		{
			Assert.That(Helper.ExpandText(
				"abc$(A)def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc_A_def"
			));
		}

		[Test]
		public void Test_SingleExpansion_MultiCharKey()
		{
			Assert.That(Helper.ExpandText(
				"abc$(ABC)def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc_ABC_def"
			));
		}

		[Test]
		public void Test_Dollar_Without_Expansion()
		{
			Assert.That(Helper.ExpandText(
				"abc$def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abcdef"
			));
		}

		[Test]
		public void Test_Dollar_Escaped()
		{
			Assert.That(Helper.ExpandText(
				"abc$$def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc$def"
			));
		}

		[Test]
		public void Test_Dollar_Escaped_2()
		{
			Assert.That(Helper.ExpandText(
				"abc$$$def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc$def"
			));
		}

		[Test]
		public void Test_Dollar_Escaped_3()
		{
			Assert.That(Helper.ExpandText(
				"abc$$$$def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc$$def"
			));
		}

		[Test]
		public void Test_OpeningBracket_Without_Expansion()
		{
			Assert.That(Helper.ExpandText(
				"abc(def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc(def"
			));
		}

		[Test]
		public void Test_OpeningBracket_Without_Expansion_2()
		{
			Assert.That(Helper.ExpandText(
				"abc((def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc((def"
			));
		}

		[Test]
		public void Test_ClosingBracket_Without_Expansion()
		{
			Assert.That(Helper.ExpandText(
				"abc)def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc)def"
			));
		}

		[Test]
		public void Test_ClosingBracket_Without_Expansion_2()
		{
			Assert.That(Helper.ExpandText(
				"abc))def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc))def"
			));
		}

		[Test]
		public void Test_Chars_Between_Dollar_And_Opening_Bracket()
		{
			Assert.That(Helper.ExpandText(
				"abc$xxx(ABC)def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abcxxx(ABC)def"
			));
		}

		[Test]
		public void Test_Missing_Closing_Bracket()
		{
			Assert.That(Helper.ExpandText(
				"abc$(def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc"
			));
		}

		[Test]
		public void Test_Dollar_In_Expansion()
		{
			Assert.That(Helper.ExpandText(
				"abc$(A$B$$C)def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc_A$B$$C_def"
			));
		}

		[Test]
		public void Test_OpeningBracket_In_Expansion()
		{
			Assert.That(Helper.ExpandText(
				"abc$(A(B((C)def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc_A(B((C_def"
			));
		}

		[Test]
		public void Test_ClosingBracket_In_Expansion()
		{
			Assert.That(Helper.ExpandText(
				"abc$(A)B))C)def",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc_A_B))C)def"
			));
		}

		[Test]
		public void Test_Sample_1()
		{
			Assert.That(Helper.ExpandText(
				"abc$(DEF)ghi$$(jkl)mno",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc_DEF_ghi$(jkl)mno"
			));
		}

		[Test]
		public void Test_Sample_2()
		{
			Assert.That(Helper.ExpandText(
				"abc$(DEF)ghi$$$(JKL)mno",
				_ExpandTextTextLookup), Is.EqualTo(
				"abc_DEF_ghi$_JKL_mno"
			));
		}

		[Test]
		public void Test_Sample_3()
		{
			Assert.That(Helper.ExpandText(
				"$(ProductVersion)",
				_ExpandTextTextLookup), Is.EqualTo(
				"_ProductVersion_"
			));
		}

		[Test]
		public void Test_Sample_4()
		{
			Assert.That(Helper.ExpandText(
				"$(ProductName) Crash Report",
				_ExpandTextTextLookup), Is.EqualTo(
				"_ProductName_ Crash Report"
			));
		}


		[Test, Ignore]
		public void Test_Performance_NoExpansion()
		{
			TestHelper.TestPerformance("NoExpansion", 1000000, i =>
			{
				Helper.ExpandText(
					"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" +
					"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
					_key => _key);
			});

			// Intel Core i5-760
			//	Count = 1000000
			//	Time = 171,8804 ms
			//	Count/ms = 5817,99902723056 1/ms
			//	Time/Call = 0,1718804 µs
		}

		[Test, Ignore]
		public void Test_Performance_OneExpansion()
		{
			TestHelper.TestPerformance("OneExpansion", 1000000, i =>
			{
				Helper.ExpandText(
					"abcdefghijklmnopqrstuvwxy$(ProductName)nopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" +
					"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
					_key => _key);
			});

			// Intel Core i5-760
			//	Count = 1000000
			//	Time = 1045,1129 ms
			//	Count/ms = 956,834424299997 1/ms
			//	Time/Call = 1,0451129 µs
		}

		[Test, Ignore]
		public void Test_Performance_MultipleExpansions()
		{
			TestHelper.TestPerformance("MultipleExpansion", 1000000, i =>
			{
				Helper.ExpandText(
					"abcdefghijklmnopqrstuvwxy$(ProductName)nopqrstuvwxyz$(ProductVersion)rstuvwxyz" +
					"abcdefg$(ProductState)wxyzabc$(Id)ijklmnop$(Timestamp)cdefghijk$(Blub)stuvwxyz",
					_key => _key);
			});

			// Intel Core i5-760
			//	Count = 1000000
			//	Time = 1207,2128 ms
			//	Count/ms = 828,35437132542 1/ms
			//	Time/Call = 1,2072128 µs
		}

		#endregion

		#region FormatException

		[Test]
		public void Test_FormatException()
		{
			var exception = new ApplicationException("MY MESSAGE");
			exception.Data.Add("value", 123.456);

			var text = Helper.FormatException(exception);

			Assert.That(text, Is.Not.Null);
			Assert.That(text, Is.Not.Empty);
			Assert.That(text, Is.StringContaining("System.ApplicationException"));
			Assert.That(text, Is.StringContaining("MY MESSAGE"));
			Assert.That(text, Is.StringContaining("value"));
			Assert.That(text, Is.StringContaining("123.456"));
		}

		[Test]
		public void Test_FormatException_CultureInfo()
		{
			var exception = new ApplicationException("MY MESSAGE");
			exception.Data.Add("value", 123.456);

			var formatProvider = new CultureInfo("de-AT");
			var text = Helper.FormatException(exception, formatProvider);

			Assert.That(text, Is.Not.Null);
			Assert.That(text, Is.Not.Empty);
			Assert.That(text, Is.StringContaining("System.ApplicationException"));
			Assert.That(text, Is.StringContaining("MY MESSAGE"));
			Assert.That(text, Is.StringContaining("value"));
			Assert.That(text, Is.StringContaining("123,456"));
		}

		#endregion

		#region FormatBuffer

		[Test]
		public void Test_FormatBuffer_Buffer()
		{
			var buffer = new Byte[] { 0x11, 0x22, 0x33 };
			Assert.That(Helper.FormatBuffer(buffer), Is.EqualTo("11;22;33"));
		}

		[Test]
		public void Test_FormatBuffer_Buffer_Empty()
		{
			var buffer = new Byte[] { };
			Assert.That(Helper.FormatBuffer(buffer), Is.EqualTo(""));
		}

		[Test]
		public void Test_FormatBuffer_BufferSegment()
		{
			var buffer = new Byte[] { 0x11, 0x22, 0x33, 0x44, 0x55 };
			var segment = new BufferSegment(buffer, 1, 3);
			Assert.That(Helper.FormatBuffer(segment), Is.EqualTo("22;33;44"));
		}

		[Test]
		public void Test_FormatBuffer_BufferSegment_Empty()
		{
			var segment = BufferSegment.Empty;
			Assert.That(Helper.FormatBuffer(segment), Is.EqualTo(""));
		}

		[Test]
		public void Test_FormatBuffer_BufferOffsetCount()
		{
			var buffer = new Byte[] { 0x11, 0x22, 0x33, 0x44, 0x55 };
			Assert.That(Helper.FormatBuffer(buffer, 1, 3), Is.EqualTo("22;33;44"));
		}

		[Test]
		public void Test_FormatBuffer_BufferOffsetCount_Empty()
		{
			var buffer = new Byte[] { 0x11, 0x22, 0x33, 0x44, 0x55 };
			Assert.That(Helper.FormatBuffer(buffer, 1, 0), Is.EqualTo(""));
		}

		#endregion

		#region GetApplicationPath

		[Test]
		public void Test_GetApplicationPath()
		{
			var path1 = Helper.GetApplicationPath();
			var path2 = Helper.GetApplicationPath();

			Assert.That(path1, Is.Not.Null);
			Assert.That(path1, Is.Not.Empty);
			Assert.That(Directory.Exists(path1), Is.True);
			Assert.That(path1, Is.EqualTo(path2));
		}

		[Test]
		public void Test_GetApplicationPath_RelativePath_Null()
		{
			Assert.Throws<ArgumentNullException>(() =>
				Helper.GetApplicationPath(null));
		}

		[Test]
		public void Test_GetApplicationPath_RelativePath_EmptyString()
		{
			var path = Helper.GetApplicationPath("");

			Assert.That(path, Is.Not.Null);
			Assert.That(path, Is.Not.Empty);
			Assert.That(path, Is.EqualTo(Helper.GetApplicationPath()));
		}

		[Test]
		public void Test_GetApplicationPath_RelativePath()
		{
			var path = Helper.GetApplicationPath("nunit.framework.dll");

			Assert.That(path, Is.Not.Null);
			Assert.That(path, Is.Not.Empty);
			Assert.That(File.Exists(path), Is.True);
		}

		#endregion

		#region GetExecutablePath, GetExecutableName

		[Test]
		public void Test_GetExecutablePath()
		{
			var path1 = Helper.GetExecutablePath();
			var path2 = Helper.GetExecutablePath();

			Assert.That(path1, Is.Not.Null);
			Assert.That(path1, Is.EqualTo(path2));
		}

		[Test]
		public void Test_GetExecutablePath_RelativePath_Null()
		{
			Assert.Throws<ArgumentNullException>(() =>
				Helper.GetExecutablePath(null));
		}

		[Test]
		public void Test_GetExecutablePath_RelativePath_EmptyString()
		{
			var path = Helper.GetExecutablePath("");

			Assert.That(path, Is.Not.Null);
			Assert.That(path, Is.Not.Empty);
			Assert.That(path, Is.EqualTo(Helper.GetExecutablePath()));
		}

		[Test]
		public void Test_GetExecutablePath_RelativePath()
		{
			var name = Helper.GetExecutableName();
			var path = Helper.GetExecutablePath(name);

			Assert.That(path, Is.Not.Null);
			Assert.That(path, Is.Not.Empty);
			Assert.That(File.Exists(path), Is.True);
		}

		[Test]
		public void Test_GetExecutableName()
		{
			var name = Helper.GetExecutableName();

			Assert.That(name, Is.Not.Null);
		}

		#endregion

		#region GetPropertyName

		private class MyClass
		{
			public static String MyStaticProperty
			{
				get;
				set;
			}

			public String MyProperty
			{
				get;
				set;
			}

			public String MyMethod()
			{
				return null;
			}
		}


		// --- TESTS ---


		[Test]
		public void Test_GetPropertyName()
		{
			var myclass = new MyClass();
			var name = Helper.GetPropertyName(() => myclass.MyProperty);

			Assert.That(name, Is.EqualTo("MyProperty"));
		}

		[Test]
		public void Test_GetPropertyName_NotAMemberAccessExpression()
		{
			var myclass = new MyClass();

			Assert.Throws<ArgumentException>(() =>
				{
					Helper.GetPropertyName(() => myclass.MyMethod());
				});
		}

		[Test]
		public void Test_GetPropertyName_NotAPropertyExpression()
		{
			var myclass = new MyClass();

			Assert.Throws<ArgumentException>(() =>
				{
					Helper.GetPropertyName(() => myclass);
				});
		}

		[Test]
		public void Test_GetPropertyName_NotAMemberPropertyExpression()
		{
			Assert.Throws<ArgumentException>(() =>
				{
					Helper.GetPropertyName(() => MyClass.MyStaticProperty);
				});
		}

		#endregion

		#region MakeWord, GetLowByte, GetHighByte

		[Test]
		public void Test_MakeWord()
		{
			Assert.That(Helper.MakeWord(0x12, 0x34), Is.EqualTo(0x1234));
			Assert.That(Helper.MakeWord(0xFE, 0xDC), Is.EqualTo(0xFEDC));
		}

		[Test]
		public void Test_GetLowByte()
		{
			Assert.That(Helper.GetLowByte(0x1234), Is.EqualTo(0x34));
			Assert.That(Helper.GetLowByte(0xFEDC), Is.EqualTo(0xDC));
		}

		[Test]
		public void Test_GetHighByte()
		{
			Assert.That(Helper.GetHighByte(0x1234), Is.EqualTo(0x12));
			Assert.That(Helper.GetHighByte(0xFEDC), Is.EqualTo(0xFE));
		}

		#endregion

		#region MakeDWord, GetLowWord, GetHighWord

		[Test]
		public void Test_MakeDWord_Words()
		{
			Assert.That(Helper.MakeDWord(0x12FE, 0x34DC), Is.EqualTo(0x12FE34DC));
			Assert.That((UInt32)Helper.MakeDWord(0xFE12, 0xDC34), Is.EqualTo((UInt32)0xFE12DC34));
		}

		[Test]
		public void Test_MakeDWord_Bytes()
		{
			Assert.That(Helper.MakeDWord(0x12, 0xFE, 0x34, 0xDC), Is.EqualTo(0x12FE34DC));
			Assert.That((UInt32)Helper.MakeDWord(0xFE, 0x12, 0xDC, 0x34), Is.EqualTo((UInt32)0xFE12DC34));
		}

		[Test]
		public void Test_GetLowWord()
		{
			Assert.That(Helper.GetLowWord(0x12FE34DC), Is.EqualTo(0x34DC));
			Assert.That(Helper.GetLowWord(unchecked((Int32)0xFE12DC34)), Is.EqualTo(0xDC34));
		}

		[Test]
		public void Test_GetHighWord()
		{
			Assert.That(Helper.GetHighWord(0x12FE34DC), Is.EqualTo(0x12FE));
			Assert.That(Helper.GetHighWord(unchecked((Int32)0xFE12DC34)), Is.EqualTo(0xFE12));
		}

		#endregion

		#region WaitForCondition

		[Test]
		public void Test_WaitForCondition_NegativeSleepTime()
		{
			Assert.Throws<ArgumentOutOfRangeException>(() =>
				Helper.WaitForCondition(TimeSpan.FromSeconds(-1), () => true));
		}

		[Test]
		public void Test_WaitForCondition_NullCondition()
		{
			Assert.Throws<ArgumentNullException>(() =>
				Helper.WaitForCondition(TimeSpan.FromSeconds(100), null));
		}

		[Test]
		public void Test_WaitForCondition()
		{
			Int32 count = 0;
			Helper.WaitForCondition(TimeSpan.FromMilliseconds(10), () => ++count == 5);

			Assert.That(count, Is.EqualTo(5));
		}

		[Test]
		public void Test_WaitForCondition_TimeoutNotReached()
		{
			var result = Helper.WaitForCondition(
				TimeSpan.FromSeconds(1),
				TimeSpan.FromMilliseconds(10),
				() => true);

			Assert.That(result, Is.True);
		}

		[Test]
		public void Test_WaitForCondition_TimeoutReached()
		{
			var result = Helper.WaitForCondition(
				TimeSpan.FromSeconds(1),
				TimeSpan.FromMilliseconds(10),
				() => false);

			Assert.That(result, Is.False);
		}

		#endregion

		#region WildcardMatch

		[Test]
		public void Test_WildcardMatch()
		{
			//  " -------------------> *"
			Assert.That(Helper.WildcardMatch("*", "a.b"), Is.True);
			Assert.That(Helper.WildcardMatch("*", "ab"), Is.True);
			Assert.That(Helper.WildcardMatch("*", "abc"), Is.True);
			Assert.That(Helper.WildcardMatch("*", ".ab"), Is.True);
			Assert.That(Helper.WildcardMatch("*", "ab."), Is.True);
			Assert.That(Helper.WildcardMatch("*", ".a.b"), Is.True);
			Assert.That(Helper.WildcardMatch("*", "a.bcd"), Is.True);
			Assert.That(Helper.WildcardMatch("*", "xyz.bcd"), Is.True);
			Assert.That(Helper.WildcardMatch("*", ".a.bcd"), Is.True);
			//  " -------------------> *.*"
			Assert.That(Helper.WildcardMatch("*.*", "a.b"), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", "ab"), Is.False);
			Assert.That(Helper.WildcardMatch("*.*", "abc"), Is.False);
			Assert.That(Helper.WildcardMatch("*.*", ".ab"), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", "ab."), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", ".a.b"), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", "a.bcd"), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", "xyz.bcd"), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", ".a.bcd"), Is.True);
			//  " -------------------> ?"
			Assert.That(Helper.WildcardMatch("?", "A"), Is.True);
			Assert.That(Helper.WildcardMatch("?", "AA"), Is.False);
			//  " -------------------> ?."
			Assert.That(Helper.WildcardMatch("?.", "A"), Is.False);
			Assert.That(Helper.WildcardMatch("?.", "AA"), Is.False);
			Assert.That(Helper.WildcardMatch("?.", "A."), Is.True);
			Assert.That(Helper.WildcardMatch("?.", ".A"), Is.False);
			//  " -------------------> .?"
			Assert.That(Helper.WildcardMatch(".?", "A"), Is.False);
			Assert.That(Helper.WildcardMatch(".?", "AA"), Is.False);
			Assert.That(Helper.WildcardMatch(".?", "A."), Is.False);
			Assert.That(Helper.WildcardMatch(".?", ".A"), Is.True);
			//  " -------------------> ?*"
			Assert.That(Helper.WildcardMatch("?*", "A"), Is.True);
			Assert.That(Helper.WildcardMatch("?*", "AA"), Is.True);
			Assert.That(Helper.WildcardMatch("?*", "A."), Is.True);
			Assert.That(Helper.WildcardMatch("?*", ".A"), Is.False);
			Assert.That(Helper.WildcardMatch("?*", "a.a"), Is.True);
			Assert.That(Helper.WildcardMatch("?*", "aaa"), Is.True);
			//  " -------------------> *?"
			Assert.That(Helper.WildcardMatch("*?", "A"), Is.True);
			Assert.That(Helper.WildcardMatch("*?", "AA"), Is.True);
			Assert.That(Helper.WildcardMatch("*?", "A."), Is.False);
			Assert.That(Helper.WildcardMatch("*?", ".A"), Is.True);
			Assert.That(Helper.WildcardMatch("*?", "a.a"), Is.True);
			Assert.That(Helper.WildcardMatch("*?", "aaa"), Is.True);
			//  " -------------------> ?A"
			Assert.That(Helper.WildcardMatch("?A", "Xa"), Is.True);
			Assert.That(Helper.WildcardMatch("?A", "xxa"), Is.False);
			Assert.That(Helper.WildcardMatch("?A", "a"), Is.False);
			Assert.That(Helper.WildcardMatch("?A", ".a"), Is.False);
			Assert.That(Helper.WildcardMatch("?A", "a."), Is.False);
			Assert.That(Helper.WildcardMatch("?A", "a.a"), Is.False);
			//  " -------------------> A?"
			Assert.That(Helper.WildcardMatch("A?", "aX"), Is.True);
			Assert.That(Helper.WildcardMatch("A?", "xxa"), Is.False);
			Assert.That(Helper.WildcardMatch("A?", "a"), Is.False);
			Assert.That(Helper.WildcardMatch("A?", ".a"), Is.False);
			Assert.That(Helper.WildcardMatch("A?", "a."), Is.False);
			Assert.That(Helper.WildcardMatch("A?", "a.a"), Is.False);
			//  " -------------------> ?*?"
			Assert.That(Helper.WildcardMatch("?*?", "a.b"), Is.True);
			Assert.That(Helper.WildcardMatch("?*?", "ab"), Is.True);
			Assert.That(Helper.WildcardMatch("?*?", "abc"), Is.True);
			Assert.That(Helper.WildcardMatch("?*?", ".ab"), Is.False);
			Assert.That(Helper.WildcardMatch("?*?", "ab."), Is.False);
			Assert.That(Helper.WildcardMatch("?*?", ".a.b"), Is.False);
			//  " -------------------> ?.?"
			Assert.That(Helper.WildcardMatch("?.?", "a.b"), Is.True);
			Assert.That(Helper.WildcardMatch("?.?", "ab"), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", "abc"), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", ".ab"), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", "ab."), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", ".a.b"), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", "a.bcd"), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", "xyz.bcd"), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", ".a.bcd"), Is.False);
			//  " -------------------> ?A?"
			Assert.That(Helper.WildcardMatch("?A?", "Xab"), Is.True);
			Assert.That(Helper.WildcardMatch("?A?", "xxab"), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", "a"), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", ".a"), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", "a."), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", "a.a"), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", ".a."), Is.False);
			//  " -------------------> *AA*"
			Assert.That(Helper.WildcardMatch("*AA*", "aa"), Is.True);
			Assert.That(Helper.WildcardMatch("*AA*", "xaab"), Is.True);
			Assert.That(Helper.WildcardMatch("*AA*", "aannn"), Is.True);
			Assert.That(Helper.WildcardMatch("*AA*", ".a.a"), Is.False);
			Assert.That(Helper.WildcardMatch("*AA*", "aa."), Is.True);
			Assert.That(Helper.WildcardMatch("*AA*", "aa.a"), Is.True);
			Assert.That(Helper.WildcardMatch("*AA*", ".a.aa"), Is.True);
			Assert.That(Helper.WildcardMatch("*AA*", "aa.ba.ba"), Is.True);
			//  " -------------------> ?AA*"
			Assert.That(Helper.WildcardMatch("?AA*", "aa"), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "xaab"), Is.True);
			Assert.That(Helper.WildcardMatch("?AA*", "aannn"), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", ".a.a"), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", ".aa."), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "baa."), Is.True);
			Assert.That(Helper.WildcardMatch("?AA*", "aa.a"), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", ".a.aa"), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "aa.ba.ba"), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "caa.ba.ba"), Is.True);
			//  " -------------------> *AA?"
			Assert.That(Helper.WildcardMatch("*AA?", "aa"), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "xaab"), Is.True);
			Assert.That(Helper.WildcardMatch("*AA?", "aannn"), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", ".a.a"), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", ".aa."), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "baa."), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "aa.a"), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", ".a.aa"), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "aa.ba.ba"), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "caa.ba.ba"), Is.False);
			//  " -------------------> *AB*CD*"
			Assert.That(Helper.WildcardMatch("*AB*CD*", "aa"), Is.False);
			Assert.That(Helper.WildcardMatch("*AB*CD*", "abcd"), Is.True);
			Assert.That(Helper.WildcardMatch("*AB*CD*", "abanabnabncd"), Is.True);
			Assert.That(Helper.WildcardMatch("*AB*CD*", "abanabnabncdef"), Is.True);
			Assert.That(Helper.WildcardMatch("*AB*CD*", ".ab.ab.ab.cd.cd."), Is.True);
			Assert.That(Helper.WildcardMatch("*AB*CD*", ".ab.cd.ab.cd.abcd."), Is.True);
			Assert.That(Helper.WildcardMatch("*AB*CD*", ".axb.cxd.ab.cd.abcd."), Is.True);
			Assert.That(Helper.WildcardMatch("*AB*CD*", ".axb.cyd.ab.cyd.axbcd."), Is.True);
			//  " -------------------> AB*CD*XY"
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "aa"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "abcdx_y"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "xab_anabnabncd_xy"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "abancdabnxyabncdef"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "abancdabnxyabncdefxy"), Is.True);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "a.ab.ab.ab.cd.cd.xy"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "ab.ab.cd.ab.cd.abcdxy."), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", ".axb.cxd.ab.cd.abcd.xy"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "ab.axb.cd.xyab.cyd.axbcd."), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "ab.axb.cd.xyab.cyd.axbcd.xy"), Is.True);
			//  " -------------------> AB*?*XY"
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abxy"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abcdx_y"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "ab.xy"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "xab_anabnabncd_xy"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abancdabnxyabncdef"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abancdabnxyabncdefxy"), Is.True);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abancda.bnxyabncdefxy"), Is.True);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "a.ab.ab.ab.cd.cd.xy"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "ab.ab.cd.ab.cd.abcdxy."), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", ".axb.cxd.ab.cd.abcd.xy"), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "ab.axb.cd.xyab.cyd.axbcd."), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "ab.axb.cd.xyab.cyd.axbcd.xy"), Is.True);
			//  " -------------------> ?.zip"
			Assert.That(Helper.WildcardMatch("?.zip", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", ".ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", "A.A.ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("?.zip", "AAAA.ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", "A.A.ZIPPO"), Is.False);
			//  " -------------------> *zip"
			Assert.That(Helper.WildcardMatch("*zip", "ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zip", ".ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zip", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zip", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zip", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zip", "A.A.ZIPPO"), Is.False);
			//  " -------------------> *.zip"
			Assert.That(Helper.WildcardMatch("*.zip", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*.zip", ".ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zip", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zip", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zip", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zip", "A.A.ZIPPO"), Is.False);
			//  " -------------------> *?.zip"
			Assert.That(Helper.WildcardMatch("*?.zip", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*?.zip", ".ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*?.zip", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*?.zip", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*?.zip", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*?.zip", "A.A.ZIPPO"), Is.False);
			//  " -------------------> ?*?.zip"
			Assert.That(Helper.WildcardMatch("?*?.zip", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?*?.zip", ".ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?*?.zip", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("?*?.zip", "A.ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?*?.zip", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("?*?.zip", "A.A.ZIPPO"), Is.False);
			//  " -------------------> *?*?.zip"
			Assert.That(Helper.WildcardMatch("*?*?.zip", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?.zip", ".ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?.zip", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*?*?.zip", "A.ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?.zip", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*?*?.zip", "A.A.ZIPPO"), Is.False);
			//  " -------------------> *?*?*.zip"
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", ".ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "A.ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "A.A.ZIPPO"), Is.False);
			//  " -------------------> a*?*?*.zip"
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", ".ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "A.A.ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "A.ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "A.A.ZIPPO"), Is.False);
			//  " -------------------> *zi?"
			Assert.That(Helper.WildcardMatch("*zi?", "ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi?", ".ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi?", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi?", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi?", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi?", "A.A.ZIPPO"), Is.False);
			//  " -------------------> *.zi?"
			Assert.That(Helper.WildcardMatch("*.zi?", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi?", ".ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zi?", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zi?", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zi?", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zi?", "A.A.ZIPPO"), Is.False);
			//  " -------------------> *zi*"
			Assert.That(Helper.WildcardMatch("*zi*", "ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi*", ".ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi*", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi*", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi*", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*zi*", "A.A.ZIPPO"), Is.True);
			//  " -------------------> *.zi*"
			Assert.That(Helper.WildcardMatch("*.zi*", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi*", ".ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zi*", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zi*", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zi*", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("*.zi*", "A.A.ZIPPO"), Is.True);
			//  " -------------------> a*?*?"
			Assert.That(Helper.WildcardMatch("a*?*?", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?", ".ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("a*?*?", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("a*?*?", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("a*?*?", "A.A.ZIPPO"), Is.True);
			//  " -------------------> ?*.?*"
			Assert.That(Helper.WildcardMatch("?*.?*", "ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?*.?*", ".ZIP"), Is.False);
			Assert.That(Helper.WildcardMatch("?*.?*", "A.A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("?*.?*", "A.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("?*.?*", "AAAA.ZIP"), Is.True);
			Assert.That(Helper.WildcardMatch("?*.?*", "A.A.ZIPPO"), Is.True);
		}

		[Test]
		public void Test_WildcardMatch_CaseSensitive()
		{
			//  " -------------------> *"
			Assert.That(Helper.WildcardMatch("*", "a.b", false), Is.True);
			Assert.That(Helper.WildcardMatch("*", "ab", false), Is.True);
			Assert.That(Helper.WildcardMatch("*", "abc", false), Is.True);
			Assert.That(Helper.WildcardMatch("*", ".ab", false), Is.True);
			Assert.That(Helper.WildcardMatch("*", "ab.", false), Is.True);
			Assert.That(Helper.WildcardMatch("*", ".a.b", false), Is.True);
			Assert.That(Helper.WildcardMatch("*", "a.bcd", false), Is.True);
			Assert.That(Helper.WildcardMatch("*", "xyz.bcd", false), Is.True);
			Assert.That(Helper.WildcardMatch("*", ".a.bcd", false), Is.True);
			//  " -------------------> *.*"
			Assert.That(Helper.WildcardMatch("*.*", "a.b", false), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", "ab", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.*", "abc", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.*", ".ab", false), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", "ab.", false), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", ".a.b", false), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", "a.bcd", false), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", "xyz.bcd", false), Is.True);
			Assert.That(Helper.WildcardMatch("*.*", ".a.bcd", false), Is.True);
			//  " -------------------> ?"
			Assert.That(Helper.WildcardMatch("?", "A", false), Is.True);
			Assert.That(Helper.WildcardMatch("?", "AA", false), Is.False);
			//  " -------------------> ?."
			Assert.That(Helper.WildcardMatch("?.", "A", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.", "AA", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.", "A.", false), Is.True);
			Assert.That(Helper.WildcardMatch("?.", ".A", false), Is.False);
			//  " -------------------> .?"
			Assert.That(Helper.WildcardMatch(".?", "A", false), Is.False);
			Assert.That(Helper.WildcardMatch(".?", "AA", false), Is.False);
			Assert.That(Helper.WildcardMatch(".?", "A.", false), Is.False);
			Assert.That(Helper.WildcardMatch(".?", ".A", false), Is.True);
			//  " -------------------> ?*"
			Assert.That(Helper.WildcardMatch("?*", "A", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*", "AA", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*", "A.", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*", ".A", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*", "a.a", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*", "aaa", false), Is.True);
			//  " -------------------> *?"
			Assert.That(Helper.WildcardMatch("*?", "A", false), Is.True);
			Assert.That(Helper.WildcardMatch("*?", "AA", false), Is.True);
			Assert.That(Helper.WildcardMatch("*?", "A.", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?", ".A", false), Is.True);
			Assert.That(Helper.WildcardMatch("*?", "a.a", false), Is.True);
			Assert.That(Helper.WildcardMatch("*?", "aaa", false), Is.True);
			//  " -------------------> ?A"
			Assert.That(Helper.WildcardMatch("?A", "Xa", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A", "xxa", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A", "a", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A", ".a", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A", "a.", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A", "a.a", false), Is.False);
			//  " -------------------> A?"
			Assert.That(Helper.WildcardMatch("A?", "aX", false), Is.False);
			Assert.That(Helper.WildcardMatch("A?", "xxa", false), Is.False);
			Assert.That(Helper.WildcardMatch("A?", "a", false), Is.False);
			Assert.That(Helper.WildcardMatch("A?", ".a", false), Is.False);
			Assert.That(Helper.WildcardMatch("A?", "a.", false), Is.False);
			Assert.That(Helper.WildcardMatch("A?", "a.a", false), Is.False);
			//  " -------------------> ?*?"
			Assert.That(Helper.WildcardMatch("?*?", "a.b", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*?", "ab", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*?", "abc", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*?", ".ab", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*?", "ab.", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*?", ".a.b", false), Is.False);
			//  " -------------------> ?.?"
			Assert.That(Helper.WildcardMatch("?.?", "a.b", false), Is.True);
			Assert.That(Helper.WildcardMatch("?.?", "ab", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", "abc", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", ".ab", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", "ab.", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", ".a.b", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", "a.bcd", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", "xyz.bcd", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.?", ".a.bcd", false), Is.False);
			//  " -------------------> ?A?"
			Assert.That(Helper.WildcardMatch("?A?", "Xab", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", "xxab", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", "a", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", ".a", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", "a.", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", "a.a", false), Is.False);
			Assert.That(Helper.WildcardMatch("?A?", ".a.", false), Is.False);
			//  " -------------------> *AA*"
			Assert.That(Helper.WildcardMatch("*AA*", "aa", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA*", "xaab", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA*", "aannn", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA*", ".a.a", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA*", "aa.", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA*", "aa.a", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA*", ".a.aa", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA*", "aa.ba.ba", false), Is.False);
			//  " -------------------> ?AA*"
			Assert.That(Helper.WildcardMatch("?AA*", "aa", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "xaab", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "aannn", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", ".a.a", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", ".aa.", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "baa.", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "aa.a", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", ".a.aa", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "aa.ba.ba", false), Is.False);
			Assert.That(Helper.WildcardMatch("?AA*", "caa.ba.ba", false), Is.False);
			//  " -------------------> *AA?"
			Assert.That(Helper.WildcardMatch("*AA?", "aa", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "xaab", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "aannn", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", ".a.a", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", ".aa.", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "baa.", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "aa.a", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", ".a.aa", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "aa.ba.ba", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AA?", "caa.ba.ba", false), Is.False);
			//  " -------------------> *AB*CD*"
			Assert.That(Helper.WildcardMatch("*AB*CD*", "aa", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AB*CD*", "abcd", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AB*CD*", "abanabnabncd", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AB*CD*", "abanabnabncdef", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AB*CD*", ".ab.ab.ab.cd.cd.", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AB*CD*", ".ab.cd.ab.cd.abcd.", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AB*CD*", ".axb.cxd.ab.cd.abcd.", false), Is.False);
			Assert.That(Helper.WildcardMatch("*AB*CD*", ".axb.cyd.ab.cyd.axbcd.", false), Is.False);
			//  " -------------------> AB*CD*XY"
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "aa", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "abcdx_y", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "xab_anabnabncd_xy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "abancdabnxyabncdef", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "abancdabnxyabncdefxy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "a.ab.ab.ab.cd.cd.xy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "ab.ab.cd.ab.cd.abcdxy.", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", ".axb.cxd.ab.cd.abcd.xy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "ab.axb.cd.xyab.cyd.axbcd.", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*CD*XY", "ab.axb.cd.xyab.cyd.axbcd.xy", false), Is.False);
			//  " -------------------> AB*?*XY"
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abxy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abcdx_y", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "ab.xy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "xab_anabnabncd_xy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abancdabnxyabncdef", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abancdabnxyabncdefxy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "abancda.bnxyabncdefxy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "a.ab.ab.ab.cd.cd.xy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "ab.ab.cd.ab.cd.abcdxy.", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", ".axb.cxd.ab.cd.abcd.xy", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "ab.axb.cd.xyab.cyd.axbcd.", false), Is.False);
			Assert.That(Helper.WildcardMatch("AB*?*XY", "ab.axb.cd.xyab.cyd.axbcd.xy", false), Is.False);
			//  " -------------------> ?.zip"
			Assert.That(Helper.WildcardMatch("?.zip", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?.zip", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *zip"
			Assert.That(Helper.WildcardMatch("*zip", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zip", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zip", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zip", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zip", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zip", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *.zip"
			Assert.That(Helper.WildcardMatch("*.zip", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zip", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zip", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zip", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zip", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zip", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *?.zip"
			Assert.That(Helper.WildcardMatch("*?.zip", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?.zip", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?.zip", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?.zip", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?.zip", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?.zip", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> ?*?.zip"
			Assert.That(Helper.WildcardMatch("?*?.zip", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*?.zip", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*?.zip", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*?.zip", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*?.zip", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*?.zip", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *?*?.zip"
			Assert.That(Helper.WildcardMatch("*?*?.zip", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?.zip", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?.zip", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?.zip", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?.zip", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?.zip", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *?*?*.zip"
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*?*?*.zip", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> a*?*?*.zip"
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?*.zip", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *zi?"
			Assert.That(Helper.WildcardMatch("*zi?", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi?", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi?", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi?", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi?", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi?", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *.zi?"
			Assert.That(Helper.WildcardMatch("*.zi?", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi?", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi?", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi?", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi?", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi?", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *zi*"
			Assert.That(Helper.WildcardMatch("*zi*", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi*", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi*", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi*", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi*", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*zi*", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> *.zi*"
			Assert.That(Helper.WildcardMatch("*.zi*", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi*", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi*", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi*", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi*", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("*.zi*", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> a*?*?"
			Assert.That(Helper.WildcardMatch("a*?*?", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?", "A.A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?", "A.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?", "AAAA.ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("a*?*?", "A.A.ZIPPO", false), Is.False);
			//  " -------------------> ?*.?*"
			Assert.That(Helper.WildcardMatch("?*.?*", "ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*.?*", ".ZIP", false), Is.False);
			Assert.That(Helper.WildcardMatch("?*.?*", "A.A.ZIP", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*.?*", "A.ZIP", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*.?*", "AAAA.ZIP", false), Is.True);
			Assert.That(Helper.WildcardMatch("?*.?*", "A.A.ZIPPO", false), Is.True);
		}

		#endregion

		#region  GetAssemblyInformationalVersion, GetAssemblyVersion, GetVersion, etc.

		[Test]
		public void Test_GetAssemblyInformationalVersion_NullAssembly()
		{
			Assert.Throws<ArgumentNullException>(() =>
				Helper.GetAssemblyInformationalVersion(null));
		}

		[Test]
		public void Test_GetAssemblyInformationalVersion()
		{
			var version = Helper.GetAssemblyInformationalVersion(typeof(Helper).Assembly);
			Assert.That(version, Is.Not.Null);
		}

		[Test]
		public void Test_GetAssemblyInformationalVersion_NotDefined()
		{
			var assembly = Assembly.LoadFrom(@"testfiles\EmptyAssemblyWithoutAttributes.dll");
			Assert.That(Helper.GetAssemblyInformationalVersion(assembly), Is.Null);
		}


		[Test]
		public void Test_GetAssemblyFileVersion_NullAssembly()
		{
			Assert.Throws<ArgumentNullException>(() =>
				Helper.GetAssemblyFileVersion(null));
		}

		[Test]
		public void Test_GetAssemblyFileVersion()
		{
			var version = Helper.GetAssemblyFileVersion(typeof(Helper).Assembly);
			Assert.That(version, Is.Not.Null);
		}

		[Test]
		public void Test_GetAssemblyFileVersion_NotDefined()
		{
			var assembly = Assembly.LoadFrom(@"testfiles\EmptyAssemblyWithoutAttributes.dll");
			Assert.That(Helper.GetAssemblyFileVersion(assembly), Is.Null);
		}


		[Test]
		public void Test_GetAssemblyVersion_NullAssembly()
		{
			Assert.Throws<ArgumentNullException>(() =>
				Helper.GetAssemblyVersion(null));
		}

		[Test]
		public void Test_GetAssemblyVersion()
		{
			var version = Helper.GetAssemblyVersion(typeof(Helper).Assembly);
			Assert.That(version, Is.Not.Null);
		}

		[Test]
		public void Test_GetAssemblyVersion_NotDefined()
		{
			var assembly = Assembly.LoadFrom(@"testfiles\EmptyAssemblyWithoutAttributes.dll");
			Assert.That(Helper.GetAssemblyVersion(assembly), Is.EqualTo("0.0.0.0"));
		}


		[Test]
		public void Test_GetVersion_NullAssembly()
		{
			Assert.Throws<ArgumentNullException>(() =>
				Helper.GetVersion(null));
		}

		[Test]
		public void Test_GetVersion()
		{
			var version = Helper.GetVersion(typeof(Helper).Assembly);
			Assert.That(version, Is.Not.Null);
		}

		[Test]
		public void Test_GetVersion_NotDefined()
		{
			var assembly = Assembly.LoadFrom(@"testfiles\EmptyAssemblyWithoutAttributes.dll");
			Assert.That(Helper.GetVersion(assembly), Is.EqualTo("0.0.0.0"));
		}


		[Test]
		public void Test_GetApplicationFrameworkVersion()
		{
			var version = Helper.GetApplicationFrameworkVersion();
			Assert.That(version, Is.Not.Null);
		}


		[Test]
		public void Test_GetApplicationVersion()
		{
			var version = Helper.GetApplicationVersion();

			if (Assembly.GetEntryAssembly() == null)
				Assert.That(version, Is.Null);
			else
				Assert.That(version, Is.Not.Null);
		}

		#endregion

		#region GetAssemblyProduct, GetAssemblyCompany, GetAssemblyCopyright

		[Test]
		public void Test_GetAssemblyProduct()
		{
			var assembly = Assembly.GetExecutingAssembly();
			Assert.That(Helper.GetAssemblyProduct(assembly), Is.EqualTo("Amarok Framework Library"));
		}

		[Test]
		public void Test_GetAssemblyProduct_NotDefined()
		{
			var assembly = Assembly.LoadFrom(@"testfiles\EmptyAssemblyWithoutAttributes.dll");
			Assert.That(Helper.GetAssemblyProduct(assembly), Is.Null);
		}

		[Test]
		public void Test_GetAssemblyProduct_Null()
		{
			Assert.Throws<ArgumentNullException>(() =>
				{
					Helper.GetAssemblyProduct(null);
				});
		}


		[Test]
		public void Test_GetAssemblyCompany()
		{
			var assembly = Assembly.GetExecutingAssembly();
			Assert.That(Helper.GetAssemblyCompany(assembly), Is.EqualTo(""));
		}


		[Test]
		public void Test_GetAssemblyCompany_NotDefined()
		{
			var assembly = Assembly.LoadFrom(@"testfiles\EmptyAssemblyWithoutAttributes.dll");
			Assert.That(Helper.GetAssemblyCompany(assembly), Is.Null);
		}

		[Test]
		public void Test_GetAssemblyCompany_Null()
		{
			Assert.Throws<ArgumentNullException>(() =>
				{
					Helper.GetAssemblyCompany(null);
				});
		}


		[Test]
		public void Test_GetAssemblyCopyright()
		{
			var assembly = Assembly.GetExecutingAssembly();
			Assert.That(Helper.GetAssemblyCopyright(assembly), Is.EqualTo("Copyright © 2011-2013 Olaf Kober"));
		}


		[Test]
		public void Test_GetAssemblyCopyright_NotDefined()
		{
			var assembly = Assembly.LoadFrom(@"testfiles\EmptyAssemblyWithoutAttributes.dll");
			Assert.That(Helper.GetAssemblyCopyright(assembly), Is.Null);
		}

		[Test]
		public void Test_GetAssemblyCopyright_Null()
		{
			Assert.Throws<ArgumentNullException>(() =>
				{
					Helper.GetAssemblyCopyright(null);
				});
		}

		#endregion

		#region GetTempPath, GetTempFile

		[Test]
		public void Test_GetTempPath()
		{
			var path1 = Helper.GetTempPath();
			var path2 = Helper.GetTempPath();

			Assert.That(path1, Is.Not.Null);
			Assert.That(path1.Exists, Is.False);
			Assert.That(path1.FullName, Is.StringContaining(Path.GetTempPath()));

			Assert.That(path2, Is.Not.Null);
			Assert.That(path2.Exists, Is.False);
			Assert.That(path2.FullName, Is.StringContaining(Path.GetTempPath()));

			Assert.That(path1, Is.Not.EqualTo(path2));
		}


		[Test]
		public void Test_GetTempFile()
		{
			var path1 = Helper.GetTempFile();
			var path2 = Helper.GetTempFile();

			Assert.That(path1, Is.Not.Null);
			Assert.That(path1.Exists, Is.False);
			Assert.That(path1.FullName, Is.StringContaining(Path.GetTempPath()));

			Assert.That(path2, Is.Not.Null);
			Assert.That(path2.Exists, Is.False);
			Assert.That(path2.FullName, Is.StringContaining(Path.GetTempPath()));

			Assert.That(path1, Is.Not.EqualTo(path2));
		}

		#endregion

	}
}

#endif
